from django.db import models
from django.contrib.auth.models import AbstractUser

class User(AbstractUser):
    """自定义用户模型类"""
    mobile = models.CharField(max_length=11,unique=True,verbose_name="手机号")
    email_active = models.BooleanField(default=False, verbose_name='邮箱验证状态')

    class Meta:
        db_table="user" # 自定义模型类对应的表名
        verbose_name="用户"
        verbose_name_plural=verbose_name

    def __str__(self):
        return self.username
# Create your models here.


class Goods_list(models.Model):
    name = models.CharField(max_length=20,verbose_name="商品名")
    price = models.CharField(max_length=20,verbose_name="价格")
    num = models.CharField(max_length=20,verbose_name="数量")
    jie = models.CharField(max_length=20,verbose_name="介绍")
    cun = models.CharField(max_length=20,verbose_name="库存")
    class Meta:
        db_table="goods_list" # 自定义模型类对应的表名
        verbose_name="商品表"
class Collect(models.Model):
    con_goods = models.ForeignKey(Goods_list,null=True,on_delete=models.SET_NULL)
    con_user = models.ForeignKey(User,null=True,on_delete=models.SET_NULL)
    class Meta:
        db_table="collect" # 自定义模型类对应的表名
        verbose_name="收藏表"

class Is_msg(models.Model):
    msg = models.CharField(max_length=10)
    img = models.CharField(max_length=10)
    class Meta:
        db_table="is_msg" # 自定义模型类对应的表名
        verbose_name="验证表"
